package com.yuwenchao.superafflatus;

/**
 * @Auther ChaooGG
 * @Date 2021-11-21 18:02
 */
public class RunnableDemo  {

    public static void main(String[] args) {


        Ticket ticket = new Ticket();
        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i=0;i<40;i++){
                    ticket.sale();
                }
            }
        },"AAAA").start();

        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i=0;i<40;i++){
                    ticket.sale();
                }
            }
        },"BBBB").start();


        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i=0;i<40;i++){
                    ticket.sale();
                }
            }
        },"CCCC").start();


    }

}

class Ticket{
    private  int number =30;

     void sale(){
        if(number>0){
            System.out.println(Thread.currentThread().getName()+"该线程卖出"+ number -- +"还剩下"+number+"张");
        }

    }
}

